package main

import (
	"fmt"
	"os"
)

func main() {
	if len(os.Args) < 2 {
		fmt.Println("need config file eg: nsqauth ./conf/config.yaml")
		return
	}
	//加载配置文件
	//初始化配置文件模块
	if err := InitConfig(os.Args[1]); err != nil {
		fmt.Printf("setting init failed, err: %v\n", err)
		return
	}
	// 读取存储信息
	GetAuthCache().Refresh()
	// 注册路由处理函数
	r := SetUpRouter(ServerConf.Mode)
	err := r.Run(fmt.Sprintf(":%d", ServerConf.Port))
	if err != nil {
		fmt.Printf("run server failed, err:%v\n", err)
		return
	}
}
